home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_libgtop.idb / usr / freeware / include / glibtop / gnuserv.h.z / gnuserv.h
Encoding:
C/C++ Source or Header  |  1999-07-16  |  4.4 KB  |  162 lines

  1. /* -*-C-*-
  2.  
  3.  Header file for the GNU Emacs server and client C code.
  4.  
  5.  This file is part of GNU Emacs.
  6.  
  7.  Copying is permitted under those conditions described by the GNU
  8.  General Public License.
  9.  
  10.  Copyright (C) 1989 Free Software Foundation, Inc.
  11.  
  12.  Author: Andy Norman (ange@hplb.hpl.hp.com), based on 
  13.          'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
  14.          Emacs distribution.
  15.  
  16.  Please mail bugs and suggestions to the author at the above address.
  17. */
  18.  
  19. /* HISTORY 
  20.  * 11-Nov-1990        bristor@simba    
  21.  *    Added EOT stuff.
  22.  */
  23.  
  24. /*
  25.  * This file incorporates new features added by Bob Weiner <weiner@mot.com>,
  26.  * Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>.
  27.  * Please see the note at the end of the README file for details.
  28.  *
  29.  * (If gnuserv came bundled with your emacs, the README file is probably
  30.  * ../etc/gnuserv.README relative to the directory containing this file)
  31.  */
  32.  
  33. #if 0
  34. static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup alpha !";
  35. #endif
  36.  
  37. #define NO_SHORTNAMES
  38.  
  39. #define PATCHLEVEL 2
  40.  
  41. #define NO_SHORTNAMES
  42. /* gnuserv should not be compiled using SOCKS */
  43. #define DO_NOT_SOCKSIFY
  44. #include <glibtop.h>
  45. #include <glibtop/error.h>
  46. #undef read
  47. #undef write
  48. #undef open
  49. #undef close
  50. #undef signal
  51.  
  52. /* Define the communication method between server and clients:
  53.  *   You can have either or both kinds of sockets, but you can't mix
  54.  *   sockets with sysv ipc
  55.  */
  56.  
  57. #define INTERNET_DOMAIN_SOCKETS
  58. #define UNIX_DOMAIN_SOCKETS
  59.  
  60. /*
  61.  * Define additional authentication protocols to be used. These methods will
  62.  * be tried before falling back to the default gnuserv protocol (based on
  63.  * the GNU_SECURE environment variable). Currently, only MIT-MAGIC-COOKIE-1
  64.  * is also supported.
  65.  *
  66.  * Comment out the next line(s) if you don't want to enable the
  67.  * appropriate authentication protocol.
  68.  */
  69.  
  70. #if defined (HAVE_XAUTH)
  71. #define AUTH_MAGIC_COOKIE
  72. #endif /* HAVE_XAUTH */
  73.  
  74. /*
  75.  * stuff related to supporting MIT-MAGIC-COOKIE-1
  76.  */
  77.  
  78. #if 0
  79. #define MCOOKIE_SCREEN "42980"   /* screen # to use as the gnuserv cookie */ 
  80. #endif
  81. #define MCOOKIE_NAME   "MAGIC-1" /* authentication protocol name */
  82. #define MCOOKIE_X_NAME "MIT-MAGIC-COOKIE-1"  /* as needed by X */
  83.  
  84.  
  85. #define DEFAUTH_NAME "GNU-SECURE"  /* name of default auth protocol */
  86. #define AUTH_TIMEOUT  15           /* # seconds to wait for auth data */
  87. #define AUTH_NAMESZ   15           /* max allows auth protocol name size */
  88.  
  89.  
  90. /*
  91.  * Pick a default communication scheme, if none was specified.
  92.  */
  93.  
  94. #if !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
  95.  
  96. /* BSD systems use Unix Domain sockets by default */
  97.  
  98. #ifdef BSD
  99. #define UNIX_DOMAIN_SOCKETS
  100. #endif
  101.  
  102. #endif /* No communication method pre-defined */
  103.  
  104. /*
  105.  * If you are using SYSV_IPC, you might want to make the buffer size bigger
  106.  * since it limits the size of requests and responses. Don't make it bigger
  107.  * than your system's max message size though (usually a couple of k) or else
  108.  * msgsend will start failing. For sockets, using the system BUFSIZ is usually
  109.  * what you want. 
  110.  */
  111.  
  112. #if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
  113. #include <sys/socket.h>
  114. #endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
  115.  
  116. #ifdef INTERNET_DOMAIN_SOCKETS
  117. #include <netdb.h>
  118. #include <netinet/in.h>
  119. #include <arpa/inet.h>
  120. #define TABLE_SIZE 101        /* The number of entries in the hash table */
  121. #define HASH(host) host        /* Rather simplistic hash function */
  122. #define DEFAULT_PORT 21490    /* default port number to use is
  123.                  * DEFAULT_PORT + uid */
  124. #endif /* INTERNET_DOMAIN_SOCKETS */
  125.  
  126. #ifdef UNIX_DOMAIN_SOCKETS
  127. #include <sys/un.h>
  128. #define HIDE_UNIX_SOCKET    /* put the unix socket in a protected dir */
  129. #endif /* UNIX_DOMAIN_SOCKETS */
  130.  
  131. #define HOSTNAMSZ 255        /* max size of a hostname */
  132. #define REPLYSIZ 300        /* max size of reply from server to client */
  133. #undef FALSE
  134. #define FALSE 0
  135. #undef TRUE
  136. #define TRUE 1
  137.  
  138. /* The casts shut Sun's compiler up and are safe in the context these
  139.    are actually used. */
  140. #define max2(x,y) (((int) (x) > (int) (y)) ? (x) : (y))
  141. #define min2(x,y) (((int) (x) < (int) (y)) ? (x) : (y))
  142.  
  143. #ifndef _NFILE            /* rough guess at maximum number of open files */
  144. #define _NFILE 20
  145. #endif
  146.  
  147. #define EOT_STR "\004"
  148. #define EOT_CHR '\004'
  149.  
  150. /* connection types */
  151. #define CONN_UNIX     0
  152. #define CONN_INTERNET 1
  153. #define CONN_IPC      2
  154.  
  155. /* function declarations */
  156. int glibtop_make_connection (const char *hostarg, int portarg, int *s);
  157.  
  158. #ifdef INTERNET_DOMAIN_SOCKETS
  159. long glibtop_internet_addr (const char *host);
  160. #endif
  161.  
  162.